const models = require('../models')
const services = require('../services')
const utils = require('../utils')

module.exports = function commonMiddleware (req, res, next) {
  req.models = models
  req.services = services

  res.success = function () {
    res.json(utils.success.apply(null, arguments))
  }

  res.error = function () {
    res.json(utils.error.apply(null, arguments))
  }

  next()
}
